<?php
namespace app\controller;

use app\BaseController;
use think\facade\Db;
class DataTest extends BaseController {
    public function initialize(){
        Db::event('before_find',function ($query){
            echo '执行了find查询操作';
        });
        Db::event('before_select',function ($query){
            echo '执行了select查询操作';
        });
        Db::event('after_update',function ($query){
            echo '执行了修改操作';
        });
    }
    public function index(){
        //$stu = Db::table('stu_info')->find('20201001');
        $stu=Db::table("stu_info")->select();
        print_r($stu);
    }
    public function update(){
        $stu=Db::table("stu_info")->save(['sid'=>20201001,'area'=>'广东深圳']);
        var_dump($stu);
    }
}